﻿CREATE TABLE [dbo].[KursTillfalle] (
    [Id]           UNIQUEIDENTIFIER NOT NULL,
    [ValId]        UNIQUEIDENTIFIER NOT NULL,
    [Skapad]       DATETIME         NOT NULL,
    [SkapadAv]     NVARCHAR (50)    NOT NULL,
    [Andrad]       DATETIME         NULL,
    [AndradAv]     NVARCHAR (50)    NULL,
    [Kursdatum]    DATETIME         NOT NULL,
    [Starttid]     TIME (0)         CONSTRAINT [DF_KursTillfalle_Starttid] DEFAULT ('00:00:00') NOT NULL,
    [Sluttid]      TIME (0)         CONSTRAINT [DF_KursTillfalle_Sluttid] DEFAULT ('00:00:00') NOT NULL,
    [Adress]       NVARCHAR (50)    CONSTRAINT [DF_KursTillfalle_Adress] DEFAULT ('') NOT NULL,
    [Sal]          NVARCHAR (50)    NULL,
    [KursId]       UNIQUEIDENTIFIER NOT NULL,
    [Kursansvarig] UNIQUEIDENTIFIER NULL,
    [Lokal]        NVARCHAR (50)    NULL,
    CONSTRAINT [PK_KursTillfalle] PRIMARY KEY CLUSTERED ([Id] ASC, [ValId] ASC),
    CONSTRAINT [FK_KursTillfalle_Kurs] FOREIGN KEY ([KursId], [ValId]) REFERENCES [dbo].[Kurs] ([Id], [ValId]),
    CONSTRAINT [FK_KursTillfalle_Person] FOREIGN KEY ([Kursansvarig], [ValId]) REFERENCES [dbo].[Person] ([Id], [ValId])
);









